using System;
using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.DC;
using DevExpress.ExpressApp.Reports;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Xpo;
using DevExpress.Xpo.DB;

namespace FeatureCenter.Module.Reports {
    [NavigationItem(false)]
    [VisibleInReports(true)]
    public class ReportsCustomParametersObject : BaseObject {
        private string name;
        public ReportsCustomParametersObject(Session session) : base(session) { }
        public string Name {
            get { return name; }
			set { SetPropertyValue("Name", ref name, value); }
        }
    }

    [DomainComponent]
    public class ReportsCustomParameters : ReportParametersObjectBase {
        private string nameContainsThisText;
        public ReportsCustomParameters(IObjectSpace objectSpace, Type reportDataType) : base(objectSpace, reportDataType) { }
        public string NameContainsThisText {
            get { return nameContainsThisText; }
            set { nameContainsThisText = value; }
        }
        public override CriteriaOperator GetCriteria() {
            if((ReportDataType == typeof(ReportsCustomParametersObject)) && !string.IsNullOrEmpty(nameContainsThisText)) {
                return CriteriaOperator.Parse("Name like '%" + nameContainsThisText + "%'");
            }
            return null;
        }
        public override SortProperty[] GetSorting() {
            if(ReportDataType == typeof(ReportsCustomParametersObject)) {
                SortProperty item = new SortProperty("Name", SortingDirection.Descending);
                return new SortProperty[] { item };
            }
            return new SortProperty[0];
        }
    }
}
